
<?php	
	
	class relative extends database
	{
		var $connection = '';	

		function relative()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from vnf_relative_product";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();		
			$sql = "Select * from vnf_relative_product ";				
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
		function AddRelative($ProductNo, $RelativeProductNo)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into vnf_relative_product(`ProductNo`, `RelativeProductNo`) values('".$ProductNo."', '".$RelativeProductNo."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdateRelative( $id, $ProductNo, $RelativeProductNo)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update vnf_relative_product set `ProductNo`='".$ProductNo."', `RelativeProductNo`='".$RelativeProductNo."' ";
			$sql .= " where RelativeID=".$id;			
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOneRelative($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from vnf_relative_product where RelativeID=".$id." ";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeleteRelative($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from vnf_relative_product";
			$sql .= " where RelativeID=".$id;			
			
			$this->setQuery($sql);
			$this->query();
		}
		
	}
?>